<%--
  Created by IntelliJ IDEA.
  User: J.TuTu
  Date: 2021/6/23
  Time: 17:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="com.gpf.entity.Book" %>
<%@ page import="com.gpf.dao.impl.BookDaoImpl" %>
<%@ page import="com.gpf.dao.BookDao" %>
<%@ page import="com.gpf.entity.User" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>删除图书</title>
    <style type="text/css">
        #before{
            text-align: center;
        }
        #head{
            background: #eeeeee;
            height: 80px;
        }
        #headLink{
            font-size: 20px;
        }
        #headWelLink{
            line-height: 80px;
            font-size: 20px;
        }
        a{
            text-decoration: none;
        }

    </style>
</head>
<body>

<%--头部信息--%>
<%
    User user =(User)session.getAttribute("user");
    if(user == null){
        response.sendRedirect("login.jsp");
    }else {
%>
<div id="head">
    <table width="100%">
        <td id="headWelLink">欢迎您：<%=user.getName()%></td>
        <td align="right" id="headLink">
            <a href="logout.jsp">安全退出</a>
        </td>
    </table>
</div>
<%
    }
%>

<%
    // 设置获取注册时的编码为UTF-8
    request.setCharacterEncoding("UTF-8");

    //获取admin.jsp页面的bookid
    Integer bookid=Integer.parseInt(request.getParameter("bookid"));


    //引入数据交互层
    BookDao dao=new BookDaoImpl();
    Book book=new Book();
    book = dao.getBook(bookid);
    System.out.println("删除的图书信息：");
    System.out.println(book);
    boolean flag=dao.deleteBook(bookid);

    if(flag){
        response.sendRedirect("admin.jsp");
    }else{
        response.sendRedirect("error.jsp");
    }
%>
</body>
</html>
